package com.jy.wms.web;

import com.alibaba.fastjson.JSONArray;
import com.jy.wms.pojo.User;
import com.jy.wms.service.LoginService;
import net.sf.json.JSON;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

@Controller
@RequestMapping("/toTest")
public class SysUserInfoRouter {
    @Autowired
    LoginService loginService;
    @RequestMapping(value = "")
    public String toTest(Model model){
        JSONArray jsonArray =loginService.getMenu2();
        System.out.println(jsonArray.toString());
        model.addAttribute("tests",jsonArray);
        return  "layout/layout";
    }
    @RequestMapping(value = "/list")
    public @ResponseBody  String list(){
        List<test> list= Arrays.asList(new test("123","123"),new test("123","456"));
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("rows",list);
        jsonObject.put("total",2);
        return  jsonObject.toString();
    }
    @RequestMapping(value = "/main")
    public String main(Model model){
        model.addAttribute("tests","test123213");
        return "layout/welcome";
    }

    @RequestMapping(value = "/menu")
    public String menu(Model model){
        model.addAttribute("tests","test123213");
        return "menu/menu";
    }
}
